package com.rabboit.config;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/8/31  20:47
 * 描述:
 */
@RabbitListener(queues = {"TEST-123-QUEUE"})
@Component
public class RabbitMessageListener1 {

    @RabbitHandler
    public void handler(Object obj, Message message, Channel channel) throws IOException, InterruptedException {

        System.out.println("==TEST-QUEUE===接收消息===="+new String(message.getBody()));



        Thread.sleep(2000);
        //确认
        //channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
        System.out.println("********************************************************");
        //channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,true);

    }

}
